var http=require('http'),qs=require('querystring');

function send(name){
    var req=http.request({
        host:'localhost',
        port:3000,
        method:'POST'
    }, function (res) {
        var body='';
        res.on('data', function (chunk) {
            body+=chunk;
        });
        res.on('end', function () {
            console.log('Response:'+body+'.');
            process.stdout.write('Enter your name:');

        });
    });
    req.end(qs.stringify({name:name}));
}

process.stdout.write('Enter your name:');
process.stdin.setEncoding('utf8');
process.stdin.resume();
process.stdin.on('data', function (name) {
    send(name.replace(/\s/g,''));//去除命令行输入回车确认时产生的空行
});